#include <jni.h>
#include <string>
#include <android/log.h>
#include "client/linux/handler/exception_handler.h"
#include "client/linux/handler/minidump_descriptor.h"

bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,void *context,bool succeeded){

    __android_log_print(ANDROID_LOG_DEBUG,"crash","Dump path:%s\n",descriptor.path());
    return succeeded;
}
void crash(){

    volatile  int*a = reinterpret_cast<volatile int*>(NULL);
    *a = 1;
}
extern "C" JNIEXPORT jstring JNICALL
Java_me_victor_breakpad_MainActivity_stringFromJNI(
        JNIEnv* env,
        jobject /* this */) {
    google_breakpad::MinidumpDescriptor descriptor("/data/data/me.victor.breakpad/cache");
    google_breakpad::ExceptionHandler eh(descriptor,NULL,DumpCallback,NULL,true,-1);
    crash();
    std::string hello = "Hello from C++";
    return env->NewStringUTF(hello.c_str());
}